:root {
	--page-bg: #333;
	--bg-error: 356deg;
	--bg-success: 118deg;
	--bg-warning: 56deg;
	--bg-button: 0deg;
}

@media (prefers-color-scheme: light) {
	:root {
		--page-bg: linear-gradient(to right, #fcf0c1, #ffcec1);
		--bg-error: 356deg;
		--bg-success: 118deg;
		--bg-warning: 56deg;
		--bg-button: 140deg;
	}
}

.toast {
	display: grid;
	grid-template-rows: 54px;
	transition: grid-template-rows 250ms ease-in-out;
}
.toast[data-type="error"] {
	--bg-current: var(--bg-error);
}
.toast[data-type="success"] {
	--bg-current: var(--bg-success);
}
.toast[data-type="warning"] {
	--bg-current: var(--bg-warning);
	& svg path {
		fill: currentColor;
		stroke: none;
	}
}

.toast_inner {
	height: 54px;
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	border: 1px solid #000;
	border-radius: 8px;
	background-color: hsl(var(--bg-current) 70% 45% / 0.2);
	@media (prefers-color-scheme: light) {
		background-color: hsl(var(--bg-current) 50% 55% / 0.6);
	}
	box-shadow: 4px 4px 0px 2px hsl(var(--bg-current) 30% 10% / 0.3);
	color: whitesmoke;
	transition: transform 350ms ease-in, opacity 350ms ease-in;
	overflow: hidden;
	& .toast_icon {
		color: hsl(var(--bg-current) 86% 45%);
		@media (prefers-color-scheme: light) {
			color: hsl(var(--bg-current) 96% 65%);
		}
	}
}

.toast_inner.toast_inner_out {
	transform: translateX(20%) scaleY(0);
}
.toast.toast_out {
	grid-template-rows: 0px;
}

.toast_icon {
	display: flex;
	align-items: center;
	& svg {
		display: block;
		width: 28px;
		height: 28px;
		& path {
			stroke: currentColor;
		}
	}
}

.toast_text {
	display: block;
	flex: 1 0 auto;
	color: hsl(var(--bg-current) 85% 85%);
	font-family: "Roboto Mono", monospace;
	font-size: 13px;
	white-space: nowrap;
	overflow: hidden;
	@media (prefers-color-scheme: light) {
		color: hsl(var(--bg-current) 30% 25%);
	}
}

.toast_close {
	width: 24px;
	height: 24px;
	padding: 0;
	background: transparent;
	border-width: 1px;
	border-radius: 4px;
	display: flex;
	justify-content: center;
	align-items: center;
	&::before,
	&::after {
		content: "";
		position: absolute;
		width: 1px;
		height: 18px;
		background: #76767699;
		background-color: hsl(var(--bg-current) 27% 42%);
		@media (prefers-color-scheme: light) {
			background-color: hsl(var(--bg-current) 15% 55%);
		}
		transform-origin: center;
		transition: background 100ms ease-in;
	}
	&::after {
		rotate: 45deg;
	}
	&::before {
		rotate: -45deg;
	}
	&:active::before,
	&:active::after {
		background-color: hsl(var(--bg-current) 27% 16%);
		@media (prefers-color-scheme: light) {
			background-color: hsl(var(--bg-current) 15% 55%);
		}
	}
}

.toastButton {
	position: absolute;
	padding: 8px 16px;
	font-weight: 700;
	border: none;
	background-color: hsl(var(--bg-button) 0% 35%);
	color: hsl(var(--bg-button) 30% 5%);
	font-family: "Roboto Mono", monospace;
	border-radius: 8px;
	cursor: pointer;
	@media (prefers-color-scheme: light) {
		background-color: hsl(var(--bg-button) 0% 75%);
		color: hsl(var(--bg-button) 30% 5%);
	}
	&::before {
		content: "";
		position: absolute;
		border-radius: inherit;
		inset: -1px;
		background-color: hsl(var(--bg-button) 0% 55%);
		z-index: -1;
		scale: 1.02;
		transition: scale 150ms ease-out;
	}
	&:active&::before {
		scale: 1;
	}
}

svg {
	display: none;
}

.toast-container {
	flex: 1;
	align-self: end;
	display: flex;
	flex-direction: column;
	gap: 16px;
	align-items: end;
	justify-content: end;
	z-index: 9999;
}

p {
	margin: 0;
}

* {
	box-sizing: border-box;
}